$(document).on('click', '#create-actions', function() {
    var buttons1 = [

        {
            text: '<div class="ml-edit-control"><span class="icon icon-jiaofeihuiyuanbianji1"></span> <p>编辑</p></div>',
            bold: true,
            display: 'inline-block',
            onClick: function() {
                $.alert("编辑");
            }
        }, {
            text: '<div class="ml-edit-control"><span class="icon icon-order"></span> <p>复制</p></div>',
            bold: true,
            display: 'inline-block',
            onClick: function() {
                $.alert("复制");
            }
        }, {
            text: '<div class="ml-edit-control"><span class="icon icon-remove"></span> <p>删除</p></div>',
            bold: true,
            display: 'inline-block',
            onClick: function() {
                $.alert("删除");
            }
        },

    ];
    var buttons2 = [{
        text: '取消',
        //        bg: '#fff'
    }];
    var groups = [buttons1, buttons2];
    $.actions(groups);
});


$(document).on('click', '.goods-popup', function(e) {
    e.preventDefault();
    $.popup('.popup-about');
});
// 点击分享
var flag = true;
$(".share").on('click', function(event) {
    event.preventDefault();
    if (flag) {
        $('.ml-share-box').css('z-index', '2010').show();
        $(".ml-share").css('z-index', '2009').show();
        flag = false;
    } else {
        $(".ml-share").hide();
        $('.ml-share-box').hide();
        flag = true
    }

    $(".ml-share").click(function(event) {
        $(this).hide();
        $('.ml-share-box').hide();
        flag = true;
    });
    /* Act on the event */
});

$(".ml-prop-box").on('click', 'li', function(event) {
    event.preventDefault();
    /* Act on the event */
    var eText = $(this).html();
    $(this).addClass('active').siblings('li').removeClass('active');
});
numControl();

function numControl() {
    var sum = 1;
    var sumAdd = $("#addNum");
    var minAdd = $("#minusNum");
    var totalNum = $("#totalNum").val();

    sumAdd.on('click', function(event) {
        event.preventDefault();
        sum++;
        if(sum > 1){
           minAdd.removeClass('disabled'); 
        }
        $("#totalNum").val(sum);
        $("#totalNums").html(sum);
        /* Act on the event */
    });
    minAdd.on('click', function(event) {
        event.preventDefault();
        sum--;
        if (sum <= 1) {
            sum = 1;
            $(this).addClass('disabled');
        }
        $("#totalNum").val(sum);
        $("#totalNums").html(sum);
    });

}


// 照片预览
var myPhotoBrowserStandalone = $.photoBrowser({
    photos: getSrc(),
    toolbar: false,
    theme: 'dark',
    loop: true
});




$(".ml-article-main").on('click', 'img', function(event) {
    event.preventDefault();
    myPhotoBrowserStandalone.open();
});
// 获取图片
function getSrc() {
    var imgs = [];
    $(".ml-article-main img").each(function(index, el) {
        imgs.push($(el).attr('src'));

    });
    return imgs;
}

// 控制音频播放
var audios = document.getElementById('audios');

var audiosCont = document.getElementById('audios-control');
console.log(audios.currentSrc);
audiosCont.addEventListener('click', function() {

    if (audios.paused) {
        $(".audios-cont").removeClass('icon-jixubofang').addClass('icon-stop');
        audios.play();

    } else {
        $(".audios-cont").removeClass('icon-stop').addClass('icon-jixubofang');
        audios.pause();
    }

});

var videos = document.getElementById('ml-video');

$(".ml-video").on('click',function(){
	if(!videos.paused){
		videos.pause();
	}else{
		videos.play();
	}
});


$.init();
